import json
import pymysql

def connect():
    path = '../data/databaseinfo.json'
    jsonfile = open(path, encoding='utf-8')

    datalist = json.load(jsonfile)
    host, user, password, db = datalist[0]['host'], datalist[0]['user'], datalist[0]['password'], datalist[0]['db']
    db = pymysql.connect(host=host, user=user, password=password, db=db)

    return db